package com.bigchui.DesignPattern.Singleton.lazy;

/**
 * 静态内部类单例
 * Created by wangzhen on 2019/3/9.
 */
public class LazyInnerClassSingleton {
    private LazyInnerClassSingleton(){
        if(LazyHolder.LAZY_INNER_CLASS_SINGLETON != null){
            try {
                throw new Exception("不允许构建多个事例");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    private static class LazyHolder{
        private static final LazyInnerClassSingleton LAZY_INNER_CLASS_SINGLETON=new LazyInnerClassSingleton();
    }
    public static final LazyInnerClassSingleton getInstance(){

        return LazyHolder.LAZY_INNER_CLASS_SINGLETON;
    }
}
